package com.hdyg.sixg.app;

import com.hdyg.sixg.entry.CountryBean;
import com.hdyg.sixg.httpUtil.HttpProxy;
import com.hdyg.sixg.httpUtil.okhttp.OkhttpProxy;
import com.hdyg.sixg.activity.common.AppManager;

import android.content.res.Configuration;
import android.support.multidex.MultiDexApplication;

import com.hdyg.sixg.mvp.base.BaseUrl;
import com.hdyg.sixg.util.ImageLoad.ImageLoadProxy;
import com.hdyg.sixg.util.ImageLoad.glide.GlideProxy;
import com.hdyg.sixg.util.LangUtil.MultiLanguageUtil;
import com.hdyg.sixg.util.LogUtils;
import com.tencent.bugly.crashreport.CrashReport;
import com.uuzuche.lib_zxing.activity.ZXingLibrary;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;

import okhttp3.Cookie;

/**
 * Created by CZB on 2018/3/26
 * 修改.
 */

public class MvpApplication extends MultiDexApplication {

    private static MvpApplication instance;
    public static Cookie cookie;
    public static List<CountryBean> countryBeanList;//全局的区域编码


    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        languageWork();
        // 图片加载框架示例话
        ImageLoadProxy.init(new GlideProxy());
        // 日志工具实例化
        LogUtils.getBuilder(this.getApplicationContext())
                .setLogSwitch(true)
                .setLog2FileSwitch(false)
                .setTag("czb")
                .create();
        // 初始化网络加载框架
        HttpProxy.init(new OkhttpProxy());
        //初始化zxing包
        ZXingLibrary.initDisplayOpinion(this);
        //bugly异常捕获
        CrashReport.initCrashReport(getApplicationContext(), BaseUrl.BUGLY_APPID, true);//上线时false
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        languageWork();
    }
    private void languageWork() {
        //自己写的工具包（如下）
        MultiLanguageUtil.autoUpdateLanguageEnviroment(this);
    }

    public static MvpApplication getContext() {
        if (instance == null) {
            instance = new MvpApplication();
        }
        return instance;
    }

}
